/**
 * 项目管理
 */
define(function (require, exports, module) {
    require('authorize');
    var $ = require('jquery');
    var util = require('util');
    var ui = require('ui');
    var angular = require("angular");
    require("angular-route");
    require('angular-interceptor');
    require("angular-ui");
    require("angular-messages");
    require('permission');
    require('service/third_channel/channel_service');
    require('global');

    angular.module('channel.controllers', [])
        .controller('channelListController', [
            '$scope',
            'channelService',
            function ($scope, service) {
                service.getChannelList({
                    search: {},
                    success: function (res) {
                        $scope.channelList = res.data;
                    },
                    fail: function (res) {
                    }
                });

                $scope.gotoChannelDetail = function (channel, expand) {
                    if (channel.can_click == '1') {
                        var channelId = channel.channel_id;

                        var params = $.param({
                            channelId: channelId,
                            token: util.getQueryParams(location.search).token,
                            expand: Number(expand)
                        });
                        location.href = "detail.shtml?" + params;
                    } else {
                        util.alert('如需开通第三方渠道接口，请联系我们的产品经理，邮箱：huangzw01@mysoft.com.cn，QQ：875959269');
                    }
                };

                $scope.downloadAPIDocUrl = service.getAPIDocUrl({});

                $scope.addChanel = function () {
                    util.alert('如需新增第三方渠道接口，请联系我们的产品经理，邮箱：huangzw@mysoft.com.cn，QQ：875959269');
                }
            }
        ]);

    angular.module('chaanelList', [
        'ngUI',
        'ngInterceptor',
        'channel.services',
        'channel.controllers'
    ]);

    angular.element(document).ready(function () {
        angular.bootstrap(document, ['chaanelList']);
    })
});